home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1998 January / PC Answers Issue 49 Cover CD January 1998.iso / Apps / Director / DATA.Z / Widget Wizard.dir / WidgtBehaviors_56_Image Cycle Cast Members.ls < prev    next >
Encoding:
Text File  |  1997-05-10  |  4.1 KB  |  107 lines

  1. property enabled, membermin, membermax, ImageCastLib, CycleStyle, goingDown, CurrentState, numstates, name
  2.  
  3. on CycleState me, name
  4.   if name = the name of me then
  5.     bumpstate_intern(me)
  6.   end if
  7. end
  8.  
  9. on setstate me, statenum
  10.   if the enabled of me then
  11.     if statenum > the numstates of me then
  12.       set statenum to the numstates of me
  13.     else
  14.       if statenum < 1 then
  15.         set statenum to 1
  16.       end if
  17.     end if
  18.     set the member of sprite the spriteNum of me to member (the membermin of me + statenum - 1) of castLib ImageCastLib
  19.   end if
  20. end
  21.  
  22. on setGoingDown me, value
  23.   set the goingDown of me to value
  24. end
  25.  
  26. on SetCycleStyle me, value
  27.   set the CycleStyle of me to value
  28. end
  29.  
  30. on bumpstate_intern me
  31.   if the enabled of me then
  32.     if the CycleStyle of me = #repeat then
  33.       if not (the goingDown of me) then
  34.         set curr to the CurrentState of me + 1
  35.         if curr > the numstates of me then
  36.           set curr to 1
  37.         end if
  38.       else
  39.         set curr to the CurrentState of me - 1
  40.         if curr < 1 then
  41.           set curr to the numstates of me
  42.         end if
  43.       end if
  44.     else
  45.       if not (the goingDown of me) then
  46.         set curr to the CurrentState of me + 1
  47.         if curr > the numstates of me then
  48.           set curr to curr - 2
  49.           set the goingDown of me to 1
  50.         end if
  51.       else
  52.         set curr to the CurrentState of me - 1
  53.         if curr < 1 then
  54.           set curr to 2
  55.           set the goingDown of me to 0
  56.         end if
  57.       end if
  58.     end if
  59.     set the CurrentState of me to curr
  60.     setstate(me, curr)
  61.   end if
  62. end
  63.  
  64. on beginSprite me
  65.   puppetSprite(the spriteNum of me, 1)
  66.   set the enabled of me to 1
  67.   set membermin to the memberNum of member membermin
  68.   set membermax to the memberNum of member membermax
  69.   set the numstates of me to the membermax of me - the membermin of me + 1
  70.   set the CurrentState of me to the memberNum of sprite the spriteNum of me - the membermin of me + 1
  71.   set the ImageCastLib of me to the number of castLib the castLibNum of sprite the spriteNum of me
  72.   setstate(me, the CurrentState of me)
  73. end
  74.  
  75. on endSprite me
  76.   puppetSprite(the spriteNum of me, 0)
  77. end
  78.  
  79. on getPropertyDescriptionList
  80.   set description to [:]
  81.   if the currentSpriteNum = 0 then
  82.     set slidedefault to 0
  83.   else
  84.     set memref to the member of sprite the currentSpriteNum
  85.     set castLibNum to the castLibNum of memref
  86.     set slidedefault to member the memberNum of member memref of castLib castLibNum
  87.   end if
  88.   addProp(description, #name, [#comment: "Item Name:", #format: #symbol, #default: #MultiState_1])
  89.   addProp(description, #membermin, [#comment: "First Image:", #format: #member, #default: slidedefault])
  90.   addProp(description, #membermax, [#comment: "Last Image:", #format: #member, #default: slidedefault])
  91.   addProp(description, #CycleStyle, [#comment: "Cycle Style:", #format: #symbol, #range: [#repeat, #Reverse], #default: #repeat])
  92.   addProp(description, #goingDown, [#comment: "Reverse Order:", #format: #boolean, #default: 0])
  93.   return description
  94. end
  95.  
  96. on getBehaviorDescription
  97.   return "Prepares a sprite to use a Series of adjacent Bitmap castmembers to represent an set of mutually exclusive states that the user can cycle through.  See below for usage.  " & RETURN & "PARAMETERS:" & RETURN & "ΓÇó Item Name - ( optional ) name of this control." & RETURN & "ΓÇó First Image - number of first castmember in the sequence." & RETURN & "ΓÇó Last Image  - number of last castmember in the sequence." & RETURN & "ΓÇó Cycle Mode - specifies how images in cycle are repeated on subsequent iterations. The Repeat mode repeats the same sequence.  The Reverse mode cycles back through the sequence in reverse order." & RETURN & "ΓÇó Reverse Order - proceed from last to first image by default." & RETURN & "MESSAGES:" & RETURN & "ΓÇó CycleState - advance to the next image in the sequence, or the previous image, if the GoingDown property is true. & RETURN & "ΓÇó SetState state_number - advance directly to position state_number in the sequence."
  98. end
  99.  
  100. on getAssocMembers
  101.   set myPropList to []
  102.   repeat with x = membermin + 1 to membermax
  103.     add(myPropList, member x of castLib ImageCastLib)
  104.   end repeat
  105.   return myPropList
  106. end
  107.